package doan.chuyennganh.model;

import java.util.ArrayList;
import java.util.Hashtable;

import android.util.Pair;

public class Attendance extends Object {
	private String date;
	private Hashtable<String, Integer> students;
	public Attendance() {
		super();
		date = "";
		students = new Hashtable<>();
	}
	public String getDate() {
		return date;
	}
	public void setDate(String date) {
		this.date = date;
	}
	public Hashtable<String, Integer> getStudents() {
		return students;
	}
	public void setStudents(Hashtable<String, Integer> students) {
		this.students = students;
	}
	public void add(Pair<String, Integer> value) {
		students.put(value.first, value.second);
	}
	public int get(String key) {
		return students.get(key);
	}
	public ArrayList<Integer> getAllValues() {
		return new ArrayList<Integer>(students.values());
	}
	
	public ArrayList<String> getAllKey() {
		return new ArrayList<String>(students.keySet());
	}
	public int getPeriod(){
		ArrayList<Integer> list = getAllValues();
		for(Integer i : list){
			if(i != 0){
				return i;
			}
		}
		return 0;
	}
	public ArrayList<String> getAllStudentAttendanced() {
		ArrayList<Integer> list = getAllValues();
		ArrayList<String> stu = getAllKey();
		ArrayList<String> res = new ArrayList<String>();
		int k = 0;
		for(Integer i : list){
			if(i == 0){
				res.add(stu.get(k));
			}
			k++;
		}
		return res;
	}
	public void setAttendanceValueForStudent(String id, int value) {
		if(id == "" || !students.containsKey(id)){
			return;
		}
		students.put(id, value);
	}
}
